//
//  QGRecentChatCell.m
//  qeegooChat
//
//  Created by heew on 16/1/7.
//  Copyright © 2016年 com.autozi. All rights reserved.
//

#import "QGRecentChatCell.h"
#import "QGRecentChatModel.h"
#import "QGCommonHeadView.h"
//#import "GJGCChatContentEmojiParser.h"

@interface QGRecentChatCell ()


@property (nonatomic,strong)IBOutlet QGCommonHeadView *headView;

@property (nonatomic,strong)IBOutlet UILabel *nameLabel;

@property (nonatomic,strong)IBOutlet UILabel *timeLabel;

@property (nonatomic,strong)IBOutlet UILabel *contentLabel;

@property (nonatomic,strong) UIView *bottomLine;

@property (nonatomic,strong)IBOutlet UILabel *unReadCountLabel;
@end

@implementation QGRecentChatCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.unReadCountLabel.layer.cornerRadius = self.unReadCountLabel.viewWidth/2;
        self.unReadCountLabel.layer.masksToBounds = YES;
        
    }
    return self;
}

+ (instancetype)cellWithTableView:(UITableView *)tableView
{
    QGRecentChatCell *cell = [tableView dequeueReusableCellWithIdentifier:@"recent"];
    if (cell == nil) {
        cell = [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self) owner:nil options:nil] lastObject];
    }
    return cell;
}
- (void)awakeFromNib {
    
    self.unReadCountLabel.layer.cornerRadius = self.unReadCountLabel.viewWidth/2;
    self.unReadCountLabel.layer.masksToBounds = YES;
}

- (void)setContentModel:(QGRecentChatModel *)contentModel
{
    if (!contentModel) {
        return;
    }
    
    [self.headView setHeadUrl:contentModel.headUrl];
    
    self.nameLabel.text = contentModel.name;
    
    self.timeLabel.text = contentModel.time;
    
    self.unReadCountLabel.text = [NSString stringWithFormat:@"%ld",(long)contentModel.unReadCount];
    self.unReadCountLabel.hidden = contentModel.unReadCount == 0? YES:NO;
    
//    NSDictionary *parseDict = [QGUitility userDefaultGetValue:contentModel.content];
////    if (!parseDict) {
////        parseDict = [GJGCChatContentEmojiParser parseContent:contentModel.content];
////    }
//    NSAttributedString *attributedString = [parseDict objectForKey:@"contentString"];
    self.contentLabel.text = contentModel.content;
    
}

@end
